home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / smail-3.1.28 / samples / bsmtp / cbsmtp.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-09-05  |  1.1 KB  |  62 lines

  1. #!/bin/sh
  2. # @(#)samples/bsmtp/cbsmtp.sh    1.5 9/6/92 04:37:49
  3.  
  4. # deliver messages accumlated into subdirectories of the
  5. # outq spool directory.  Subdirectory names are based on
  6. # the actual hostnames involved:
  7.  
  8. LOCALHOST=veritas.veritas.com
  9. MAXSIZE=100000
  10.  
  11. OUTQ=/usr/spool/smail/outq
  12. UUX=/usr/bin/uux
  13. COMPRESS=/usr/local/bin/compress
  14.  
  15. cd $OUTQ || exit 1
  16.  
  17. # loop through all of the subdirectories
  18. for host in *
  19. do
  20.     (
  21.     # change to directory or exit subshell
  22.     test -d $host || exit
  23.     cd $host || exit 1
  24.  
  25.     # send multiple batches
  26.     while :
  27.     do
  28.         # get the list of message files; quit if none
  29.         msgs="`ls 2>/dev/null | grep '^q'`"
  30.         test -n "$msgs" || break
  31.  
  32.         # accumulate until total size exceeds maximum
  33.         send=
  34.         sz=0
  35.         for f in $msgs
  36.         do
  37.             send="$send $f"
  38.             n=`wc -c <$f 2>/dev/null`
  39.             test -n "$n" || continue
  40.             sz=`expr $sz + $n`
  41.             test $sz -lt $MAXSIZE || break
  42.         done
  43.  
  44.         # send compressed messages, adding HELO and QUIT commands
  45.         ( echo "HELO <$LOCALHOST>"
  46.           for f in $send
  47.           do
  48.               cat $f
  49.           done
  50.           echo QUIT ) | $COMPRESS | $UUX - $host!rsmtp
  51.  
  52.         # remove messages that were sent
  53.         for f in $send
  54.         do
  55.             rm $f
  56.         done
  57.     done
  58.     )
  59. done
  60.  
  61. exit 0
  62.